<script>
import Common from "@/mixins/order/common.js";
import OrderService from "@/api/order/OrderService.js";
import PPMForm from "@/crm3.0part7-ppm/core/ppmForm.vue";
import pageShowDetail from "@/utils/pageShowDetail.js";
import { mapState } from "vuex";
import { constants } from 'os';
export default {
  name: "zfhs10450",
  mixins: [PPMForm, Common],
  data() {

        return {

        };
    },
  computed: {
    ...mapState("user", ["user", "busiManagerId", "custManagerId"]),
  },
  mounted() {
     
     //资源调查信息
     if(this.structData.structId == '10461368'){
       
        //接入方式
        this.formData["10461368-100013696"].disabled = true;
        // 接入类别
        this.formData["10461368-100013697"].disabled = true;
        //端口来源
        this.formData["10461368-100012584"].disabled = true;
      }

       if(this.structData.structId == '1940'){
          
          this.Isshow("0","10461369");
          this.Isshow("0","10461370");


          var cacheInfo  = JSON.parse(sessionStorage.getItem("cacheInfo"));
          

          var productId = cacheInfo.productId;
           this.Isshow("1","10461377");
            console.log(this.formData);
          if ("80008002" != productId && "80008007" != productId
            && "80007005" != productId && "80007006" != productId
            && "80007007" != productId && "80007008" != productId) {
              this.formData["10461377-142002262"].isshow = false;
              // this.formData["10461377-142000619"].isshow = false;
              this.Isshow("0","10461378");
            }
            var taskId = cacheInfo.taskId;
            var OrgId = cacheInfo.orgId;
            if ("1944889" == OrgId || "1944890" == OrgId || "1944891" == OrgId
            || "442" == OrgId || "1950850" == OrgId || "1978013" == OrgId) {//国际公司集团国际部保持原状
              this.Isshow("0","10461377");
              this.Isshow("0","10461378")
            }

            // var serviceOfferId = cacheInfo.offerId;
            // if ("4010100000" != serviceOfferId && "4040700001" != serviceOfferId) {//除新装补点保持原状
            //   this.Isshow("0","10461377");
            //   this.Isshow("0","10461378");
            // }

            if(productId == '80008087'){
              this.formData["10461375-100010651"].disabled = "true";
            }
            var orderItemIds = cacheInfo.orderItemIds;
            
            
            if(cacheInfo.orderItemIds.indexOf(",") > 0){
              this.Isshow("0","10461372");
              this.Isshow("0","10461373");
              this.Isshow("0","10461374");
            }else{
              // this.formData["10461375-100010735"].isshow = false;
              // this.formData["10461375-100010736"].isshow = false;
            }

          if (productId == "80008001" || productId == "80008002"
            || productId == "80008003" || productId == "80008019") {
            //是否互通,汇聚点空余汇聚能力,设备产商,设备型号,主控板软件版本

          }

          var custOrder = JSON.parse(localStorage.getItem("custOrder_select"));
             let temp = {
              custId: custOrder.custId,
              orderSource: "ORDER",
              custSoNumber: custOrder.custSoNumber,
              orderItemIds: orderItemIds,
              taskId:taskId
            };
            this.setPageOfferDetail(temp);

       }
    },
    computed: {
      },
    methods: {
      async setPageOfferDetail(temp) {

      //根据核实资费task寻找到资源填报的taskId
      //TACHE00040001
// TACHE00040002
// TACHE00040003
    // TACHE00040005
// TACHE00040008
// TACHE00040011
     var  myTaskId= temp.taskId;
      if(temp.taskId == "TACHE00050001"){
        temp.taskId = "TACHE00040001";
      }else if(temp.taskId == "TACHE00050002"){
        temp.taskId = "TACHE00040002";
      }else if(temp.taskId == "TACHE00050003"){
        temp.taskId = "TACHE00040003";
      }else if(temp.taskId == "TACHE00050005"){
        temp.taskId = "TACHE00040005";
      }else if(temp.taskId == "TACHE00050008"){
        temp.taskId = "TACHE00040008";
      }else if(temp.taskId == "TACHE00050011"){
        temp.taskId = "TACHE00040011";
      }



      
      let res = await OrderService.qryPageOfferDetail(temp);
      
      if (res.resultCode == "0") {
        pageShowDetail.RewObject(res,this.formData,temp);
        this.inputModeChange();



      if(temp.taskId == 'TACHE00040001'){
        //甲端
        var acctTypeCd = '100';
        // this.formData["10461371-100012523"].disabled = true;
      }else if(temp.taskId == 'TACHE00040002'){
        //乙端
        var acctTypeCd = '200';
      }

      // console.log("intittttttt");
      var acctItem = res.ORDER_DETAIL[0].ACCT_ITEM.filter(item =>{return item.acctTypeCd == acctTypeCd});
      this.formData["10461371-100012523"].value = acctItem[0].amount;
      this.formData["10461371-100012523"].attrRoleCd =acctTypeCd;
      this.formData["10461375-100010651"].value = acctItem[0].currency;
      this.formData["10461375-100012076"].value = acctItem[0].fixOnceFlag;
      this.fixOnceChange(acctItem[0].fixOnceFlag);
      this.formData["10461376-100012440"].value = this.$util.dateFormat(new Date(),"yyyy-MM-dd");
      this.formData["10461376-100013915"].value = "";
      this.formData["10461376-100012377"].value = this.user.staffName;

      var acctItemOrg = res.ORDER_DETAIL[0].ACCT_ITEM_ORG.filter(item =>{return item.chargeOrgCd == acctTypeCd});
      this.formData["10461375-100011975"].value = acctItemOrg[0].chargeOrgCode;
      this.formData["10461375-100013366"].value = acctItemOrg[0].conChargeOrgCode;
      this.formData["10461375-100011975"].text = acctItemOrg[0].chargeOrgName;
      this.formData["10461375-100013366"].text = acctItemOrg[0].conChargeOrgName;

        var orderTask = res.ORDER_DETAIL[0].ORDER_TASK.filter(item =>{return item.taskId == myTaskId});

        this.formData["10461376-100012611"].value = this.$util.dateFormat(orderTask[0].taskReqDate,"yyyy-MM-dd");

      }
        if(this.formData["10461371-100012523"].value == "" || this.formData["10461371-100012523"].value == "0" || this.formData["10461371-100012523"].value == null){
          // console.log("10461371-100012523",this.formData["10461371-100012523"].value);
          this.formData["10461371-100012523"].value = "";
          this.formData["10461371-100012523"].value = "0";
        }
     },
      aaa(){
        
      },
      inputModeChange(){
        var val = this.formData["10461368-100013696"].value;
        

        if(val == "80050060002"){
          this.Isshow("0","10461373");
          this.Isshow("0","10461374");
          // this.SetRequired({ attrName:'', formkey:'10461372-100011406', reqName:'empty', reqStatus:true});
          // this.SetRequired({ attrName:'', formkey:'10461372-100012553', reqName:'empty', reqStatus:true});
        }else if(val == "80050060003"){
          this.Isshow("0","10461372");
          this.Isshow("0","10461374");
          // this.SetRequired( { attrName:'', formkey:'10461373-100011404', reqName:'empty', reqStatus:true});
          // this.SetRequired({ attrName:'', formkey:'10461373-100011301', reqName:'empty', reqStatus:true});
        }else if(val == "80050060004"){
          this.Isshow("0","10461372");
          this.Isshow("0","10461373");
          // this.SetRequired({ attrName:'', formkey:'10461374-100012764', reqName:'empty', reqStatus:true});
          // this.SetRequired( { attrName:'', formkey:'10461374-100012765', reqName:'empty', reqStatus:true});
        }else if(val == null || val == '' || val == undefined){
          this.Isshow("0","10461372");
          this.Isshow("0","10461373");
          this.Isshow("0","10461374");
        }
      },
      equipMoney(val){
        if (val > 60000) {
            this.$message({
              type: "warn",
              message: "设备费不能超过60000元!",
            });
            val = 0;
          }
      },
      async fixOnceChange(val){
          if(val == "1"){
           // this.formData["10461371-100013338"].disabled  = true;
            this.formData["10461371-100012523"].disabled = true;
         //   this.formData["1940-100012523"].disabled = true;
  /*          if(this.formData["10461368-100013696"].val == "80050060002"){
              this.formData["10461372-100011406"].disabled = "disabled";
            }else if(this.formData["10461368-100013696"].val == "80050060003"){
              this.formData["10461373-100011404"].disabled = "disabled";
              this.formData["10461373-100011301"].disabled = "disabled";
            }else if(this.formData["10461368-100013696"].val == "80050060004"){
              this.formData["10461374-100012764"].disabled = "disabled";
              this.formData["10461374-100012765"].disabled = "disabled";
            }*/
          }else{
               var custOrder = JSON.parse(localStorage.getItem("custOrder_select"));
              let params = {
                    interFaceType: "ORDER",
                    sqlId: "2021081202",
                    paramStr: "custSoNumber:"+custOrder.custSoNumber+";custId:"+custOrder.custId
                };
               let result = await OrderService.executeSql(params);
               if (result.code == 200) {
               let res = result.meta.resList.executeSqlResps[0];
               console.log(res);  
               if (res.orgId =="1944640") {
                  this.formData["10461371-100012523"].disabled = true;
                }
               }
          }

      },

  },
};
</script>

